<?php
/**
 * 定义f:option控件
 *
 * @package if
 * @subpackage module.ui
 * @since 1.1.0
 */
class UIFormOption extends UIFormElement {
	protected $tpl = "form_option";
	
	function render() {
		//是否在select中
		$select = $this->parent("f:select");
		if ($select) {
			$value = $this->attr("value");
			if (!if_empty($value)) {
				$selectedValue = $this->request($select->attr("name"), true);
				if ((is_array($selectedValue) && in_array($value, $selectedValue)) || $selectedValue == $value) {
					$this->setAttr("selected", "selected");
				}
			}
		}
		
		//label
		if (!$this->attr("label")) {
			$this->setAttr("label", $this->content());
		}
		
		return parent::render();
	}
}

?>